package com.hongmeng.web.controller.operater.operaterUser;

import com.hongmeng.operater.domain.operaterUser.HmDoctorAgent;
import com.hongmeng.operater.service.operaterUser.IHmDoctorAgentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hongmeng.common.annotation.Log;
import com.hongmeng.common.core.controller.BaseController;
import com.hongmeng.common.core.domain.AjaxResult;
import com.hongmeng.common.enums.BusinessType;
import com.hongmeng.common.utils.poi.ExcelUtil;
import com.hongmeng.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 医生经纪人信息Controller
 *
 * @author hongmeng
 * @date 2021-02-22
 */
@ApiOperation("医生经纪人信息Controller")
@RestController
@RequestMapping("/operater/doctorAgent")
public class HmDoctorAgentController extends BaseController
{
    @Autowired
    private IHmDoctorAgentService hmDoctorAgentService;

    /**
     * 查询医生经纪人信息列表
     */
    @ApiOperation("查询医生经纪人信息列表")
    @PreAuthorize("@ss.hasPermi('operater:doctorAgent:list')")
    @GetMapping("/list")
    public TableDataInfo list(HmDoctorAgent hmDoctorAgent)
    {
        startPage();
        List<HmDoctorAgent> list = hmDoctorAgentService.selectHmDoctorAgentList(hmDoctorAgent);
        return getDataTable(list);
    }

    /**
     * 导出医生经纪人信息列表
     */
    @PreAuthorize("@ss.hasPermi('operater:doctorAgent:export')")
    @Log(title = "医生经纪人信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HmDoctorAgent hmDoctorAgent)
    {
        List<HmDoctorAgent> list = hmDoctorAgentService.selectHmDoctorAgentList(hmDoctorAgent);
        ExcelUtil<HmDoctorAgent> util = new ExcelUtil<HmDoctorAgent>(HmDoctorAgent.class);
        return util.exportExcel(list, "doctorAgent");
    }

    /**
     * 获取医生经纪人信息详细信息
     */
    @ApiOperation("获取医生经纪人信息详细信息")
    @PreAuthorize("@ss.hasPermi('operater:doctorAgent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(hmDoctorAgentService.selectHmDoctorAgentById(id));
    }

    /**
     * 新增医生经纪人信息
     */
    @ApiOperation("新增医生经纪人信息")
    @PreAuthorize("@ss.hasPermi('operater:doctorAgent:add')")
    @Log(title = "医生经纪人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HmDoctorAgent hmDoctorAgent)
    {
        return hmDoctorAgentService.insertHmDoctorAgent(hmDoctorAgent);
    }

    /**
     * 修改医生经纪人信息
     */
    @ApiOperation("修改医生经纪人信息")
    @PreAuthorize("@ss.hasPermi('operater:doctorAgent:edit')")
    @Log(title = "医生经纪人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmDoctorAgent hmDoctorAgent)
    {
        return hmDoctorAgentService.updateHmDoctorAgent(hmDoctorAgent);
    }

    /**
     * 删除医生经纪人信息
     */
    @ApiOperation("删除医生经纪人信息")
    @PreAuthorize("@ss.hasPermi('operater:doctorAgent:remove')")
    @Log(title = "医生经纪人信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(hmDoctorAgentService.deleteHmDoctorAgentByIds(ids));
    }
}